#ifndef ROBOT_H
#define ROBOT_H

#include "Engine.hpp"
#include "Event.hpp"
#include "SensorPoller.hpp"
#include "State.hpp"

/**
 * The Robot itself.
 * This class is the brains of our robot.
 * More detailed description.
 * ARIE: DEZE IS VOOR JOU
 */
class Robot
{
public:
	/**
	 * Get robot instance
	 * @return the robot instance
	 */
	static Robot& getInstance();

	/**
	 * Handle a new event
	 * @param event A new event
	 */
	void handleEvent(Event& event);

	/**
	 * Change the robot state to the given state
	 * @param state New robot state
	 */
	void changeState(State* newState);

	/**
	 * Get the current robot state
	 */
	State* getState();

	/**
	 * Get the engine
	 */
	Engine& getEngine();

	/**
	 * Initialize robot
	 */
	void init();

	/**
	 * (Re)start the robot
	 */
	void restart();

	/**
	 * Update the robot. This will polls all the sensors, spawn any relevant events and handle them.
	 */
	void update();

private:
	/**
	 * Handles a new EmergencyStopActivatedEvent
	 */
	void handleEmergencyStopActivatedEvent();

	/**
	 * Robot constructor, requires a start state
	 * @param aStartState The state the robot should start in
	 */
	Robot(State* aStartState);


	Robot(Robot const&); // Not implemented
	void operator=(Robot const&); // Not implemented

	Engine engine;
	State* currentState;
	SensorPoller sensorPoller;
};
#endif
